# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libproxy
pkgver=0.5.3
pkgrel=0
pkgdesc="Library handling all the details of proxy configuration"
url="https://github.com/libproxy/libproxy"
arch="all"
license="LGPL-2.0-or-later"
makedepends="
	curl-dev
	duktape-dev
	glib-dev
	gobject-introspection-dev
	gsettings-desktop-schemas-dev
	meson
	python3
	vala
	"
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-bin
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/libproxy/libproxy/archive/$pkgver.tar.gz
	no-git.patch
	"
builddir="$srcdir/libproxy-$pkgver"

# secfixes:
#   0.4.15-r9:
#     - CVE-2020-26154
#   0.4.15-r8:
#     - CVE-2020-25219

build() {
	abuild-meson \
		-Db_lto=true \
		-Dtests="$(want_check && echo true || echo false)" \
		-Ddocs=false \
		. output
	meson compile -C output
}

check() {
	meson test --no-rebuild --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

bin() {
	pkgdesc="Binary to test libproxy"

	amove usr/bin/proxy
}

gnome3() {
	pkgdesc="$pkgdesc (GNOME 3 integration)"
	install_if="$pkgname=$pkgver-r$pkgrel gnome-desktop"

	amove usr/lib/libproxy/$pkgver/modules/config_gnome3.so
	amove usr/lib/pxgsettings
}

kde() {
	pkgdesc="$pkgdesc (KDE integration)"
	install_if="$pkgname=$pkgver-r$pkgrel plasma-desktop"

	amove usr/lib/libproxy/$pkgver/modules/config_kde.so
}

pacrunner() {
	pkgdesc="$pkgdesc (pacrunner integration)"

	amove usr/lib/libproxy/$pkgver/modules/config_pacrunner.so
}

sha512sums="
0fa4c677372afa76a9f143abb1472af1df85e1190425ec4168b98e575a9b9c9fe3dcc56062609da8ef266d56dfb153e7f7a1c15aed2d385003d9f3f421d08590  libproxy-0.5.3.tar.gz
c850e55796fe82cee0a7315773af4f73f59c88783ad09a27a0f7514f6e03a37b6c04b5f995ffaaab47208e6ad6c5cce7be0fb2192ef523d6c9f0bb99be261f12  no-git.patch
"
